package com.controller;

import com.common.contant.RestResponse;
import com.common.vo.PageResult;
import com.dto.TbSpuDTO;
import com.service.GoodsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: sijunqiang
 * @Date: 2020/6/4 18:13
 * @Description: 商品控制层
 */
@RestController
@Slf4j
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class GoodsController {

    private final GoodsService goodsService;


    /**
     * 查询spu分页
     */
    @GetMapping(value = "spu/page")
    public RestResponse<PageResult<TbSpuDTO>> querySpuByPage(
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "rows", defaultValue = "5") Integer rows,
            @RequestParam(value = "saleable", required = false) Boolean saleable,
            @RequestParam(value = "key", required = false) String key) {
        log.info(">>>开始：查询spu分页 page:[{}],rows:[{}],saleable:[{}],key:[{}]", page, rows, saleable, key);
        return goodsService.querySpuByPage(page, rows, saleable, key);
    }


}
